package com.gmscosmo.model;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

public class Participant {
    private String display;
    private Long publisher_id;
    private Long session_id;
    private Long handle_id;
    private HashMap<String, Long> handleIds;
    private String host;
    private Integer node;
    private boolean inRoom;

    public Participant(){
        Random random = new Random();
        this.publisher_id = Math.abs(random.nextLong());
    }

    public String getTargetUserId(long handle_id){
        for(Map.Entry<String,Long> map:handleIds.entrySet()){
            if(map.getValue()==handle_id){
                return map.getKey();
            }
        }
        return null;
    }
    public String getDisplay() {
        return display;
    }

    public void setDisplay(String display) {
        this.display = display;
    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public Integer getNode() {
        return node;
    }

    public void setNode(Integer node) {
        this.node = node;
    }

    public Long getPublisher_id() {
        return publisher_id;
    }

    public void setPublisher_id(Long publisher_id) {
        this.publisher_id = publisher_id;
    }

    public Long getSession_id() {
        return session_id;
    }

    public void setSession_id(Long session_id) {
        this.session_id = session_id;
    }

    public HashMap<String, Long> getHandleIds() {
        return handleIds != null ? handleIds : new HashMap<>(16);
    }

    public void setHandleIds(HashMap<String, Long> handleIds) {
        this.handleIds = handleIds;
    }

    public Long getHandle_id() {
        return handle_id;
    }

    public void setHandle_id(Long handle_id) {
        this.handle_id = handle_id;
    }

    public boolean isInRoom() {
        return inRoom;
    }

    public void setInRoom(boolean inRoom) {
        this.inRoom = inRoom;
    }

    @Override
    public String toString() {
        return "Participant{" +
                "display='" + display + '\'' +
                ", publisher_id=" + publisher_id +
                ", session_id=" + session_id +
                ", handle_id=" + handle_id +
                ", handleIds=" + handleIds +
                ", host='" + host + '\'' +
                ", node=" + node +
                ", inRoom=" + inRoom +
                '}';
    }

}
